package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import com.ticket.sass.common.entity.tenant.enums.DouyinGoodsRedeemStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author ywb
 * @since 2024-07-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("douyin_goods_redeem_records")
@ApiModel(value="DouyinGoodsRedeemRecordsEntity对象", description="")
public class DouyinGoodsRedeemRecordEntity implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "券码一次核销的标识")
    private String verifyId;

    @ApiModelProperty(value = "券码的标识")
    private String certificateId;

    @ApiModelProperty(value = "商家总店id")
    private String accountId;

    @ApiModelProperty(value = "抖音团购券的12位或15位原始券码")
    private String originCode;

    @ApiModelProperty(value = "核销状态 0: 待核销 1: 成功 2: 失败")
    private DouyinGoodsRedeemStatus status;

    private String productName;
    private String encryptedCode;
    private Integer couponNum;
    private LocalDateTime redeemedAt;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    private Integer cinemaId;

    private Integer tenantId;
    
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;
    
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;
    
    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;

    @ApiModelProperty(value = "订单的标识")
    private String orderId;

    public boolean isAlreadyRedeemed() {
        return status == DouyinGoodsRedeemStatus.SUCCESS;
    }
}
